home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DClap / DTableView.h < prev    next >
Text File  |  1996-07-05  |  5KB  |  157 lines

  1. // DTableView.h
  2. // d.g.gilbert
  3.  
  4. #ifndef _DTABLEVIEW_
  5. #define _DTABLEVIEW_
  6.  
  7. #include "DPanel.h"
  8. #include "DCommand.h"
  9. #include "DTracker.h"
  10. #include "DMethods.h"
  11. #include "DTabSelect.h"
  12.  
  13.  
  14. class DTableView : public DAutoPanel, public DPrintHandler
  15. {
  16. public:
  17.         DTabSelector * fTabSelector; 
  18.         DTracker * fCurrentTracker;
  19.         DTabSelection * fSelection;
  20.         
  21.         DTableView(long id, DView* itsSuperior,  
  22.                     short pixwidth, short pixheight, 
  23.                     long nrows, long ncols,
  24.                     short itemwidth, short itemheight,
  25.                     Boolean hasVscroll = true, Boolean hasHscroll = true);
  26.         virtual ~DTableView();
  27.         
  28.         virtual void SetTableFont( Nlm_FonT itsFont);
  29.         virtual void SetTableSize( long rows, long cols);
  30.         virtual void ChangeRowSize( long atrow, long deltarows);
  31.         virtual void ChangeColSize( long atcol, long deltacols);
  32.         
  33.         virtual void SetItemWidth(long atcol, long ncols, short itemwidth);
  34.         virtual void SetItemHeight(long atrow, long nrows, short itemheight);
  35.         virtual void SetScrollPage();
  36.         
  37.         virtual void FindLocation();
  38.         virtual void Resize(DView* superview, Nlm_PoinT sizechange);
  39.         virtual void SizeToSuperview( DView* super, Boolean horiz, Boolean vert);
  40.         virtual void ViewRect(Nlm_RecT& r); 
  41.  
  42.         virtual void Scroll(Boolean vertical, DView* scrollee, long newval, long oldval);
  43.         virtual Nlm_Boolean ScrollIntoView( Nlm_RecT itemr);
  44.             
  45.         virtual void GetRowRect( long row, Nlm_RecT& r, long nrows = 1);
  46.         virtual void GetColRect( long col, Nlm_RecT& r, long ncols = 1);
  47.         virtual void GetCellRect( long row, long col, Nlm_RecT& r);
  48.         virtual void GetCellRect( Nlm_RecT cellr, Nlm_RecT& r);
  49.         virtual void PointToCell(Nlm_PoinT mouse, long& row, long& col);
  50.             
  51.         virtual void TrackFeedback( short aTrackPhase,
  52.                     const Nlm_PoinT& anchorPoint, const Nlm_PoinT& previousPoint,
  53.                     const Nlm_PoinT& nextPoint, Nlm_Boolean mouseDidMove, Nlm_Boolean turnItOn);
  54.         virtual void TrackMouse( short aTrackPhase,
  55.                     Nlm_PoinT& anchorPoint, Nlm_PoinT& previousPoint,
  56.                     Nlm_PoinT& nextPoint,    Nlm_Boolean mouseDidMove);
  57.         
  58.         virtual void SingleClickAt(long row, long col);
  59.         virtual void DoubleClickAt(long row, long col);
  60.         virtual void Click(Nlm_PoinT mouse);
  61.         virtual void Drag(Nlm_PoinT mouse);
  62.         virtual void Release(Nlm_PoinT mouse);
  63.  
  64.         virtual void DrawCell(Nlm_RecT r, long row, long col);
  65.         virtual void DrawRow(Nlm_RecT r, long row);
  66.         virtual void Draw();
  67.         virtual void InvertRect( Nlm_RecT& r);
  68.         virtual void Print();
  69.         virtual void WriteToPICT(DFile* afile); 
  70.         virtual void GetPageCount(Nlm_RecT pagerect, long& rowpages, long& colpages);
  71.         virtual long GetItemWidth(long atcol = 0);
  72.         virtual long GetItemHeight(long atrow = 0);
  73.  
  74.         virtual void GetPixRgn( Nlm_RecT cellrect, Nlm_RegioN cellrgn, Nlm_RegioN pixrgn);
  75.         virtual void InvertRgn( Nlm_RegioN pixrgn);
  76.         
  77.         Nlm_FonT GetFont() { return fFont; }
  78.         void SelectFont() { Nlm_SelectFont(fFont); }
  79.         long GetMaxRows() { return fMaxRows; }
  80.         long GetMaxCols() { return fMaxCols; }
  81.         Nlm_RecT GetRect() { return fRect; }
  82.         long    GetLeft() { return fLeft; }
  83.         long GetTop()    { return fTop; }
  84.         void SetLeft( long val) { fLeft = val; }
  85.         void SetTop( long val)    { fTop = val; }
  86.  
  87.         void SetCanSelect( Boolean canrow, Boolean cancol)
  88.             { fSelection->SetCanSelect(canrow, cancol); }
  89.         long GetSelectedRow() 
  90.             { return fSelection->GetSelectedRow(); }
  91.         long GetSelectedCol() 
  92.             { return fSelection->GetSelectedCol(); }
  93.         Nlm_RecT GetSelRect() 
  94.             { return fSelection->GetSelRect(); }
  95.         void GetFirstSelectedCell( long& row, long& col)
  96.             { fSelection->GetFirstSelectedCell(row, col); }
  97.         void GetLastSelectedCell( long& row, long& col)
  98.             { fSelection->GetLastSelectedCell(row, col); }    
  99.         void SelectCells( long row, long col, 
  100.                 short extend = DTabSelection::kDontExtend, Nlm_Boolean highlight = true, Nlm_Boolean select = true)
  101.             { fSelection->SelectCells(row, col, extend, highlight, select); }
  102.         void SelectCells( Nlm_RecT selrect,  
  103.                 short extend = DTabSelection::kDontExtend, Nlm_Boolean highlight = true, Nlm_Boolean select = true)
  104.             { fSelection->SelectCells(selrect, extend, highlight, select); }
  105.         void SetEmptySelection(Boolean redraw = true)
  106.             { fSelection->SetEmptySelection(redraw); }
  107.         void InvalidateSelection()
  108.             { fSelection->InvalidateSelection(); }
  109.         Boolean IsSelected()
  110.             { return fSelection->IsSelected(); }
  111.         Boolean IsSelected(long row, long col)
  112.             { return fSelection->IsSelected(row, col); }
  113.         void InvertSelection()
  114.             { fSelection->InvertSelection(); }
  115.         
  116. protected:
  117.         short        *fWidths, *fHeights;
  118.         long        fMaxRows, fMaxCols;
  119.         short        fItemHeight, fItemWidth;
  120.         long        fTop, fLeft, fColsDrawn;
  121.         long        fHScrollScale, fVScrollScale;
  122.         Boolean    fHasVbar, fHasHbar, fIsPrinting;
  123.         Nlm_RecT    fRect;
  124.         Nlm_FonT    fFont;
  125. };
  126.  
  127.  
  128. class DRCshifter : public DTracker 
  129. {
  130. public:
  131.     enum { kDoCol= 0, kDoRow= 1 };
  132.     Nlm_Boolean fRowCol;
  133.     long             fNewRC, fOldRC;
  134.     DTableView    * fTable;
  135.     
  136.     DRCshifter() 
  137.     {
  138.         IRCshifter( 0, NULL, NULL, kDoRow, 0);
  139.     }
  140.         
  141.     DRCshifter( long command, DTaskMaster* itsSource, DTableView* itsTable, 
  142.                             Nlm_Boolean RowOrCol, long oldRC) 
  143.     {
  144.          IRCshifter( command, itsSource, itsTable, RowOrCol, oldRC);
  145.     }
  146.          
  147.     void IRCshifter( long command, DTaskMaster* itsSource, DTableView* itsTable, 
  148.                             Nlm_Boolean RowOrCol, long oldRC)
  149.     {
  150.          fTable= itsTable; fRowCol= RowOrCol; fNewRC= -1; fOldRC= oldRC;
  151.          ITracker(command,  itsSource, "shift", kCanUndo, kCausesChange,
  152.                                  itsTable);
  153.     }
  154.      
  155. };
  156. #endif
  157.